package view
{
import data.RadioEvents;

import flash.display.MovieClip;
	import flash.events.EventDispatcher;
	import data.RadioEvents;
	import flash.events.Event
	import flash.events.MouseEvent
	/**
	 * ...
	 * @author yaempechenki@gmail.com
	 */
	public class UIMuteButton extends EventDispatcher
	{
		private var _visual:MovieClip;
		private var _state:Boolean = true;
		public function UIMuteButton(visual:MovieClip) 
		{
			_visual = visual;
			_visual.addEventListener(MouseEvent.CLICK, _onClk);
			_visual.buttonMode = true;
			_update();
		}
		
		private function _onClk(event:MouseEvent):void
		{
			_state = !_state;
			_update();
			dispatchEvent(new Event(RadioEvents.VOLUME_MUTE));
		}
		
		private function _update():void 
		{
			if (_state) {
				_visual.gotoAndStop(1);
			} else {
				_visual.gotoAndStop(2);
			}
		}
		
		public function get state():Boolean
		{
			return _state;
		}
		
		public function set state(val:Boolean):void 
		{
			_state = val;
			_update();
		}
	}

}